package com.skivingcloud.report.service.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.skivingcloud.report.entity.ReportRangeAuthUser;
import com.skivingcloud.report.mapper.ReportRangeAuthUserMapper;
import com.skivingcloud.report.service.ReportRangeAuthUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.skivingcloud.common.utils.PageParameter;

/**
 * 授权用户表 服务层实现。
 *
 * @author skivingcloud
 * @since 2024-11-07
 */
@Service
public class ReportRangeAuthUserServiceImpl extends ServiceImpl<ReportRangeAuthUserMapper, ReportRangeAuthUser> implements ReportRangeAuthUserService {

    /**
     * 分页查询授权用户表
     *
     * @param parameter 查询参数
     * @return 分页查询结果
     */
    @Override
    public Page<ReportRangeAuthUser> queryByPage(PageParameter<ReportRangeAuthUser> parameter){
        Page<ReportRangeAuthUser> page = new Page<>(parameter.getPage(), parameter.getPageSize());
        QueryWrapper queryWrapper = QueryWrapper.create();
        if (parameter.getParam() != null) {
            //查询条件
            if (StringUtils.isNoneBlank(parameter.getParam().getId())) {
                queryWrapper.and(ReportRangeAuthUser::getId).like(parameter.getParam().getId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getTplId())) {
                queryWrapper.and(ReportRangeAuthUser::getTplId).like(parameter.getParam().getTplId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getSheetId())) {
                queryWrapper.and(ReportRangeAuthUser::getSheetId).like(parameter.getParam().getSheetId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getRangeAuthId())) {
                queryWrapper.and(ReportRangeAuthUser::getRangeAuthId).like(parameter.getParam().getRangeAuthId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getUserId())) {
                queryWrapper.and(ReportRangeAuthUser::getUserId).like(parameter.getParam().getUserId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getType())) {
                queryWrapper.and(ReportRangeAuthUser::getType).like(parameter.getParam().getType());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getCreator())) {
                queryWrapper.and(ReportRangeAuthUser::getCreator).like(parameter.getParam().getCreator());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getUpdater())) {
                queryWrapper.and(ReportRangeAuthUser::getUpdater).like(parameter.getParam().getUpdater());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getDelFlag())) {
                queryWrapper.and(ReportRangeAuthUser::getDelFlag).like(parameter.getParam().getDelFlag());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getAuthType())) {
                queryWrapper.and(ReportRangeAuthUser::getAuthType).like(parameter.getParam().getAuthType());
            }
        }
        return this.page(page, queryWrapper);
    }
}
